package com.chao.tlias.service.impl;

import com.chao.tlias.Pojo.Dept;
import com.chao.tlias.mapper.DeptMapper;
import com.chao.tlias.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> list() {//查询全部部门信息
        return deptMapper.list();
    }

    @Override
    public void deleteById(Integer id) {//删除部门
        deptMapper.deleteById(id);
    }

    @Override
    public void add(Dept dept) {//添加部门
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());

        deptMapper.insret(dept);
    }

    @Override
    public Dept selectById(Integer id) {//根据ID查询部门
        return deptMapper.selectById(id);
    }

    @Override
    public void updateDept(Dept dept) {//修改部门
        dept.setUpdateTime(LocalDateTime.now());

            deptMapper.updateDept(dept);
    }


}
